package com.homework;

public class Student {
    
    private String name;
    private int id;
    private int score;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public int getScore() {
        return score;
    }
    public void setScore(int score) {
        this.score = score;
    }
    public Student(String name, int id, int score) {
        super();
        this.name = name;
        this.id = id;
        this.score = score;
    }

    public void show() {
        System.out.println("id:"+id+",name="+name+",score="+score);
    }

    public static void sort(Student[] stus) {
        Student stu;
        for(int i = 0;i < stus.length-1;i++) {
            for(int j = 0;j < stus.length - i - 1;j++) {
                if(stus[j].score > stus[j+1].score) {
                    stu = stus[j];
                    stus[j] = stus[j+1];
                    stus[j+1] = stu;
                }
            }
        }
    }


    public static void main(String[] args) {
        Student[] stus = new Student[3];
        stus[0] = new Student("Tom", 1, 89);
        stus[1] = new Student("Jerry", 2, 65);
        stus[2] = new Student("Scott", 3, 77);

        Student.sort(stus);

        for(Student stu : stus) {
            stu.show();
        }

    }


}



